<?php

class Page_model extends Model{

	var $table_name = 'page';
	var $table_name2 = 'page_item';
	
	function Page_model()
	{
		parent::Model();
	}
	
	function get_row($field,$where_field = '',$where_value = '')
	
	{
		$this->db->select($field);	
		if($where_value<>''):
			$this->db->where($where_field,$where_value);
		endif;
		$this->db->where('status','A');
		
		$query = $this->db->get($this->table_name);	
		return $query;
	}	
	
	function get_row_page_item($field,$where_field = '',$where_value = '')
	{
		$this->db->select($field);	
		if($where_value<>''):
			$this->db->where($where_field,$where_value);
		endif;
		$this->db->where('status','A');
		
		$query = $this->db->get($this->table_name2);	
		return $query;
	}
	
	function get_rows($field,$where_field='',$where_value='')
	{
		$this->db->select($field);	
		if($where_field){
			$this->db->where($where_field,$where_value);
		}		
		$this->db->where('status','A');
		$this->db->orderby('sort','ASC');
		$query = $this->db->get($this->table_name);	
		return $query;
		
	}
	
	function get_rows_page_item($field,$where_field='',$where_value='')
	{
		$this->db->select($field);	
		if($where_field){
			$this->db->where($where_field,$where_value);
		}		
		$this->db->where('status','A');
		$this->db->orderby('sort','ASC');
		$query = $this->db->get($this->table_name2);	
		return $query;
		
	}
	
	function get_rows_join($field,$where_field='',$where_value='',$show=0, $start=0)
	{
		$this->db->select($field);	
		$this->db->from($this->table_name);
		$this->db->join($this->table_name2, $this->table_name . '.id = ' . $this->table_name2 . '.page_id');

		if($where_field){
			$this->db->where($where_field,$where_value);
		}		
		
		if($show > 0)
		{
			$this->db->limit($show,$start);	
		}
		
		$this->db->where($this->table_name.'.status','A');
		$this->db->where($this->table_name2.'.status','A');
		$this->db->orderby($this->table_name2.'.sort','ASC');
		$query = $this->db->get();	
		return $query;
		
	}
}

/* End of file News_model.php */
/* Location: ./system/application/models/blog_model.php */	
?>